package com.jiutong.meipenggang.http.present;

import android.content.Context;

import com.jiutong.meipenggang.common.Constants;
import com.jiutong.meipenggang.entity.InvestMoneyBean;
import com.jiutong.meipenggang.http.model.interfaces.InvestMoneyBiz;
import com.jiutong.meipenggang.http.model.requests.MeiLiCaiFragmentRequest;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;
import com.jiutong.meipenggang.http.subscribers.SubscriberOnNextListener;
import com.jiutong.meipenggang.utils.SpConfig;

import java.util.HashMap;

/**
 * @author Veken
 * @date on 2017/12/21 18:01
 * @describe
 */

public class InvestMoneyPresent {

    private Context mContext;
    private MeiLiCaiFragmentRequest meiLiCaiFragmentRequest;
    private InvestMoneyBiz investMoneyBiz;

    public InvestMoneyPresent(Context mContext, InvestMoneyBiz investMoneyBiz) {
        this.mContext = mContext;
        this.investMoneyBiz = investMoneyBiz;
        meiLiCaiFragmentRequest = new MeiLiCaiFragmentRequest();
    }

    public void getInvestMoneyInfo(){
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<InvestMoneyBean>() {
            @Override
            public void onNext(InvestMoneyBean object) {
                investMoneyBiz.onSuccess(object);
            }

            @Override
            public void onError(Throwable e) {
                investMoneyBiz.onError(e);
            }
        };

        HashMap<String,Object> hashMap = new HashMap<>();
        hashMap.put("OPT",investMoneyBiz.getOpt());
        hashMap.put("bidId",investMoneyBiz.bidId());
        hashMap.put("id", SpConfig.getInstance().getString(Constants.ID));
        hashMap.put("token",SpConfig.getInstance().getString(Constants.TOKEN));

        meiLiCaiFragmentRequest.getInvestMoneyInfo(new ProgressSubscriber(onNextListener,mContext),hashMap);
    }
}
